Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

deResource.hpp

Go to the documentation of this file.
00001 ///////////////////////////////////////////////////////////////////////////////
00002 /// @file deResource.hpp
00003 ///
00004 /// @brief Global resource handler
00005 ///
00006 /// @author Assassin
00007 ///
00008 /// This file is the intellectual property of Novus Delta, LLC.. Usage of the
00009 /// contents of this file is subject to the Destiny3D Member License which
00010 /// can be found at http://www.destiny3d.com.  Any other usage is prohibited.
00011 ///
00012 /// This file is distributed "AS IS" without warranty of any kind.  Novus
00013 /// Delta, LLC. does not guarantee the fitness of the contents of this file
00014 /// for any particular purpose.
00015 ///
00016 /// Copyright (C) 2001-2003 Novus Delta, LLC. All Rights Reserved.
00017 ///
00018 /// <hr>
00019 ///                                 Change History
00020 /// <hr>
00021 ///
00022 /// @date Aug 2001
00023 /// @author Assassin
00024 /// @remarks Creation
00025 ///
00026 /// @date Feb 2002
00027 /// @author Hootie
00028 /// @remarks Level 2 Singleton DLL Wrap
00029 ///
00030 ///////////////////////////////////////////////////////////////////////////////
00031 
00032 #ifndef DERESOURCE_HPP
00033 #define DERESOURCE_HPP
00034 
00035 
00036 
00037 //=================================================================================
00038 // Includes
00039 //=================================================================================
00040 #include "deGlobalTypes.hpp"
00041 
00042 
00043 //=================================================================================
00044 // DLL Import/Export Defines
00045 //=================================================================================
00046 
00047 #if defined(DERESOURCE_DLL_EXPORTS) || defined(DESTINY3D_EXPORT_ALL)
00048 #   define DERESOURCE_API extern "C" DEDLL_EXPORT
00049 #elif defined(DESTINY3D_STATIC_LINK)
00050 #   define DERESOURCE_API extern "C"
00051 #else
00052 #   define DERESOURCE_API extern "C" DEDLL_IMPORT
00053 #endif
00054 
00055 #ifdef USING_DESTINY3D
00056 #ifdef _DEBUG
00057 #   ifdef DESTINY3D_STATIC_LINK
00058 #       pragma comment(lib, "deResource_sd")
00059 #   else
00060 #       pragma comment(lib, "deResourced")
00061 #   endif //DESTINY3D_STATIC_LINK
00062 #else
00063 #   ifdef DESTINY3D_STATIC_LINK
00064 #       pragma comment(lib, "deResource_s")
00065 #   else
00066 #       pragma comment(lib, "deResource")
00067 #   endif //DESTINY3D_STATIC_LINK
00068 #endif //_DEBUG
00069 #endif //USING_DESTINY3D
00070 
00071 // get rid of the annoying diamond-inheritance warning
00072 #pragma warning (disable : 4250)
00073 
00074 //=================================================================================
00075 // Forward declarations
00076 //=================================================================================
00077 
00078 class IdeResourceBase;
00079 class IdeResourceManager;
00080 class IdeFileSystem;
00081 class IdeFile;
00082 
00083 
00084 //=================================================================================
00085 // Destiny Resource Manager Interface Factories
00086 //=================================================================================
00087 
00088 /// Retrieve the Resource Manager singleton
00089 DERESOURCE_API IdeResourceManager *IdeResourceManager_GetManager();
00090 DERESOURCE_API void IdeResourceManager_ShutDown();
00091 /// a type to use to retrieve the function pointer
00092 typedef IdeResourceManager* (*fIdeResourceManager_GetManager)();
00093 
00094 
00095 
00096 //=================================================================================
00097 // Typedefs
00098 //=================================================================================
00099 
00100 /// used to register file types
00101 typedef IdeResourceBase *(*deResourceMakerCB)(const char *filename, IdeFile *file, deBoolean isThreaded);
00102 
00103 
00104 
00105 //=================================================================================
00106 // IdeResourceBase Class
00107 //
00108 // Interface class which all resource handling must be done through
00109 //=================================================================================
00110 
00111 /// Used for handling objects that can be created from files.
00112 /// Related classes: IdeResourceManager.
00113 //class IdeResourceBase : virtual public IdeRefCountBase
00114 DE3D_INTERFACE(IdeResourceBase, IdeRefCountBase)
00115 {
00116 protected:
00117     virtual ~IdeResourceBase()  {};
00118 public:
00119     /// Used to retrieve a pointer to an interface registered through IdeResourceManager.
00120     /// @return NULL or a valid pointer to an interface supported by this object
00121     /// @param interface_id A value previously retrieved through IdeResourceManager::GetUniqueInterfaceID
00122     virtual void * GetRscInterface(long interface_id) = 0;
00123 
00124     /// tells whether or not the object has been modified since it was loaded from file
00125     virtual deBoolean IsDirty(void) = 0;
00126     /// @return pointer to the object's internal name entry
00127     virtual const char *GetFilename(void) = 0;
00128     /// fills buffer with the filename of the object, until the entire name is stored
00129     ///  or 'buffersize' characters are written
00130     virtual void GetFilenameBuffer(char *buffer, long buffersize) = 0;
00131     /// create a copy of the object in memory
00132     virtual IdeResourceBase *MakeCopy(void) = 0;
00133 
00134     //only for use by deResourceManager, otherwise BAD things happen
00135     virtual void SetHash(void *HashTable) = 0;
00136     virtual void *GetHash(void) = 0;
00137     virtual void SetManager(IdeResourceManager *Manager) = 0;
00138     virtual IdeResourceManager *GetManager(void) = 0;
00139 };
00140 
00141 
00142 //=================================================================================
00143 // IdeResourceManager Class
00144 //
00145 // Resource Manager interface
00146 //=================================================================================
00147 
00148 /// the head honcho as far as resources are concerned.
00149 /// Related functions: IdeResourceManager_GetManager.
00150 /// Related classes: IdeResourceBase.
00151 //class IdeResourceManager
00152 DE3D_INTERFACE_(IdeResourceManager)
00153 {
00154 protected:
00155     virtual ~IdeResourceManager()  {};
00156 public:
00157     /// Used by classes derived from IdeResourceBase to resolve interfaces
00158     /// @return a value that is unique relative to all other values returned by this method
00159     virtual long GetUniqueInterfaceID() = 0;
00160     /// Register a file extension so that files can be created from it
00161     /// @return deFalse on failure, deTrue on success
00162     /// @param extension a file extension in the form "bmp". The extension cannot contain dots
00163     /// @param maker a pointer to a function that will return an instance of the class associated with the extension
00164     virtual deBoolean RegisterResourceType(const char* extension, deResourceMakerCB maker) = 0;
00165     /// Retrieves a "clean" instance of the specified file
00166     /// @return Pointer to a "clean" object that has the filename specified. It may be created from a file
00167     ///                 specified, or it may retrieve a pointer to an instance already in the internal database.
00168     /// @param filename A standard filename of the format "path/file.ext"
00169     /// @param filesystem Either NULL or a valid pointer to a filesystem to be searched for the filename.
00170     ///                   If NULL is used, the behavior of the maker function may be undefined
00171     /// @param DoLoad If set to deFalse, the file will not be loaded if it does not already exist in memory
00172     virtual IdeResourceBase* GetResource(const char* filename, IdeFileSystem* filesystem, deBoolean doLoad = deTRUE) = 0;
00173     virtual IdeResourceBase* GetResourceThreaded(const char* filename, IdeFileSystem* filesystem, deBoolean doLoad = deTRUE) = 0;
00174     virtual IdeResourceBase* GetResourceFromFile(IdeFile* file, const char* filename, deBoolean record = deTRUE) = 0;
00175     virtual IdeResourceBase* GetResourceFromFileThreaded(IdeFile* file, const char* filename, deBoolean record = deTRUE) = 0;
00176     /// Removes a resource from the internal database
00177     /// @param resource a valid pointer to an object to remove
00178     virtual deBoolean RemoveResource(IdeResourceBase* resource) = 0;
00179     /// Will remove all the objects from the internal database
00180     virtual deBoolean RemoveAllResources(void) = 0;
00181 };
00182 
00183 
00184 
00185 
00186 
00187 
00188 
00189 #endif  //End: DERESOURCE_HPP
00190 

Generated on Mon Sep 12 19:58:36 2005 for Destiny3D by doxygen1.3-rc3